import request from '../../router/axios'

export function getClassCharacterPage(params) { // 分页获取分类属性
  return request({
    url: '/admin/sys/class/character/page',
    method: 'get',
    params
  })
}

export function addCharacter(data) { // 新增分类属性
  return request({
    url: '/admin/sys/class/character/add',
    method: 'post',
    data
  })
}

export function updateCharacter(data) { // 更新分类属性
  return request({
    url: '/admin/sys/class/character/update',
    method: 'put',
    data
  })
}

export function getClassCharacterList(orgId) { // 获取分类属性列表
  return request({
    url: '/admin/sys/class/character/list',
    method: 'get',
    params: {
      orgId
    }
  })
}

export function getvalue(characterId) { // 根据分类属性id获取其属性值
  return request({
    url: '/admin/sys/class/character/getvalue/' + characterId,
    method: 'get',
    // params: {
    //   characterId
    // }
  })
}

export const getValueByTableNameAndField = (tableName, columnName) => request({ // 根据表名+字段查询数据
  url: '/admin/dataBase/table/column/value/list',
  method: 'get',
  params: {
    tableName,
    columnName
  }
})

export function getClassByTableName(tableName) { // 根据表名获取分类
  return request({
    url: '/admin/sys/class/list/bytablename',
    method: 'get',
    params: {
      tableName
    }
  })
}

export function addClass(classId, objectId, tableName) { // 添加分类关联
  return request({
    url: '/admin/sys/class/relation/add',
    method: 'post',
    params: {
      classId,
      objectId,
      tableName
    }
  })
}

export function removeClass(classId, objectId, tableName) { // 移除分类关联
  return request({
    url: '/admin/sys/class/relation/remove',
    method: 'post',
    params: {
      classId,
      objectId,
      tableName
    }
  })
}

export function saveClassCharacter(data) { // 保存某对象id的分类属性值
  return request({
    url: '/admin/sys/class/character/save',
    method: 'post',
    data
  })
}


export function getClassCharacter(objectId, tableName, isHidden) { // 获取某对象id的分类属性值
  return request({
    url: '/admin/sys/class/character/values',
    method: 'get',
    params: {
      objectId,
      tableName,
      isHidden
    }
  })
}
